package leetcode;

public class Four {
    public static void main(String[] args) {
        int[] arr1 = new int[]{1,3,8,10,11};
        int[] arr2 = new int[]{2,4,6,7,9};
        int i = 0, j = 0, k = 0, m1 = 0, m2 = 0;
        int mid = (arr1.length + arr2.length) / 2;
        while (k <= mid && (i < arr1.length || j < arr2.length)) {
            m1 = m2;
            if (i == arr1.length || (i != arr1.length && j != arr2.length && arr2[j] < arr1[i]))
                m2 = arr2[j++];
            else
                m2 = arr1[i++];
            k++;
        }
        double a = (arr1.length + arr2.length) % 2 == 1 ? (double) m2 : (double) (m1 + m2) / 2;
    }
}
